package cn.schoolwow.util.test.module.query.resource.testcase;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.domain.query.resource.QueryResource;
import cn.schoolwow.util.domain.query.resource.QueryResourceResponse;
import cn.schoolwow.util.module.query.resource.domain.SingleQueryResourceHandler;
import org.junit.Assert;

import java.net.URL;

public class WalkResourceTestCase2Flow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        QueryResource.newQuery("用户角色组合列表", "module/query/resource/walk")
                .ignoreDirectory(true)
                .singleQueryResourceHandler(new SingleQueryResourceHandler() {
                    @Override
                    public boolean handleQueryResourceResponse(QueryResourceResponse queryResourceResponse) {
                        URL url = queryResourceResponse.getAsURL();
                        Assert.assertFalse(url.toString().endsWith("/"));
                        return true;
                    }
                })
                .execute()
                .walkResource();
    }

    @Override
    public String name() {
        return "遍历文件夹2测试用例";
    }
}
